<template>
  <div
    class="recommend-article"
    @click="detail(article.id, article.isNeedPassword)"
  >
    <div class="recommend-article-cover">
      <img class="cover-img" :src="article.coverPathDesc" alt="" />
      <span class="cover-img-screen"></span>
    </div>
    <div class="recommend-article-info">
      <div class="tag">
        <b>{{ article.tagNames[0] }}</b>
        <em v-for="(it, i) in article.tagNames" :key="i"># {{ it }}</em>
      </div>
      <div class="title-container">
        <span class="title-inner">{{ article.title }}</span>
        <svg-icon
          v-if="article.isNeedPassword"
          name="lock"
          class="svg-icon"
        ></svg-icon>
      </div>

      <p v-html="article.content"></p>
      <div class="article-footer">
        <img :src="article.creatorAvatar" alt="" />
        <span class="creator-name">{{ article.creatorName }}</span>
        <span class="time">发布于 {{ article.gmtCreate }}</span>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import SvgIcon from '@/components/SvgIcon.vue';
import { ArticleListVO } from '@/pages/index/index.ts';

defineProps<{
  article: ArticleListVO;
  detail: Function;
}>();
</script>

<style scoped lang="less">
.recommend-article {
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  border-radius: 15px;
  box-shadow: var(--crane-ring-offset-shadow, 0 0 #0000),
    var(--crane-ring-shadow, 0 0 #0000), var(--crane-shadow);
  transition: all 0.3s;
  display: flex;
  flex-direction: column;
  cursor: pointer;

  .recommend-article-cover {
    width: 100%;
    height: 35%;
    background-color: var(--bg-color);
    border-radius: 15px 0 0 15px;
    position: relative;

    .cover-img {
      position: absolute;
      background-repeat: no-repeat;
      background-size: cover;
      border-radius: 15px 15px 0 0;
      display: block;
      height: 120%;
      -o-object-fit: cover;
      object-fit: cover;
      width: 100%;
      z-index: 20;
    }

    .cover-img-screen {
      background: linear-gradient(
        130deg,
        rgb(36, 198, 220),
        rgb(84, 51, 255) 41.07%,
        rgb(255, 0, 153) 76.05%
      );
      height: 120%;
      opacity: 0.4;
      pointer-events: none;
      position: absolute;
      left: 0;
      width: 100%;
      z-index: 30;
      max-width: 120%;
      mix-blend-mode: screen;
      border-radius: 15px 15px 0 0;
    }

    &::after {
      pointer-events: none;
      content: '';
      position: absolute;
      z-index: 35;
      top: 13%;
      left: 0;
      height: 120%;
      width: 100%;
      background: var(--article-cover);
    }
  }

  .recommend-article-info {
    height: 65%;
    background-color: var(--background-secondary);
    border-radius: 0 0 15px 15px;
    position: relative;
    padding: 0 15px;
    cursor: pointer;
    display: flex;
    flex-direction: column;

    .tag {
      width: 100%;
      position: relative;
      z-index: 1000;
      font-size: 14px;

      b {
        color: var(--text-accent);
      }

      em {
        margin-left: 10px;
        color: var(--font-color-sign);
      }
    }

    .title-container {
      width: 100%;
      display: flex;
      align-items: center;
      z-index: 10000;

      .title-inner {
        font-size: 25px;
        margin-top: 20px;
        margin-bottom: 20px;
        font-weight: 800;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: calc(100% - 60px);
      }

      .svg-icon {
        width: 30px;
        height: 30px;
        margin-left: 30px;
      }
    }

    p {
      overflow: hidden;
      text-overflow: ellipsis;
      display: -webkit-box;
      -webkit-line-clamp: 3;
      -webkit-box-orient: vertical;
      word-wrap: break-word;
      word-break: break-all;
      font-size: 16px;
    }

    .article-footer {
      display: flex;
      align-items: center;
      justify-content: flex-start;
      flex: 1 1 0;
      font-size: 14px;
      width: 100%;

      img {
        width: 40px;
        height: 40px;
        border-radius: 40px;
        box-shadow: var(--crane-ring-offset-shadow, 0 0 #0000),
          var(--crane-ring-shadow, 0 0 #0000), var(--crane-shadow);
        border-style: solid;
        border-color: var(--background-primary);
      }

      span {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }

      .creator-name {
        margin-left: 10px;
        font-weight: 600;
      }

      .time {
        margin-left: 10px;
        color: var(--font-color-sign);
      }
    }
  }

  &:hover {
    transform: scale(1.02);
  }
}
</style>
